<?php
namespace app\common\model;
use app\common\model\ManagerGongzi as ManagerGongziModel;

class ManagerGongzi extends Base
{
    protected function initialize()
    {
        parent::initialize();
    }

    public static function gongziUpdate($where)
    {
        //工资信息
        $gongzi = ManagerGongziModel::getOne($where);

        // 招新人数
        $zhaoxin_where = array(
            'time' => array('eq', $gongzi['time']),
            'mid' => array('eq', $gongzi['mid'])
        );
        $zhaoxin = ManagerStudent::getCount($zhaoxin_where);

        //课时
        $keshi_where = array(
            'time' => array('like',$gongzi['time'] . '%'),
            'manager_name' =>array('eq',$gongzi['name'])
        );
        $keshi = StudentKaoqin::getCount($keshi_where);

        // 配置
        $config = Config::getColumn(array(),'name,value');

        $save = array(
            'jichu' => $config['jichu_gongzi'],
            'zhaoxin' => $config['zhaoxin_gongzi'] * $zhaoxin ,
            'keshi' => $config['keshi_gongzi'] * $keshi,
            'update_time' => time()
        );
       ManagerGongzi::update($save,$where);
    }
}